package com.topscore.uke.ui.activities;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.topscore.uke.R;
import com.topscore.uke.entities.StaffInfoEntity;
import com.topscore.uke.mvp.contractors.GetStaffInfoContractor;
import com.topscore.uke.mvp.presenters.GetStaffInfoPresenter;
import com.topscore.uke.ui.ToolBarCompatActivity;
import com.topscore.utillibrary.widget.CircleImageView;

import butterknife.Bind;
import butterknife.ButterKnife;

public class StaffInformationActivity extends ToolBarCompatActivity implements GetStaffInfoContractor.View {

    @Bind(R.id.avatar_iv)
    CircleImageView avatarIv;
    @Bind(R.id.gender_tv)
    TextView genderTv;
    @Bind(R.id.emp_num_tv)
    TextView empNumTv;
    @Bind(R.id.phone_tv)
    TextView phoneTv;
    @Bind(R.id.wechat_tv)
    TextView wechatTv;
    private String mRole;
    private String mUserId;
    private GetStaffInfoPresenter mInfoPresenter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_staff_information);
        ButterKnife.bind(this);
        setCentralTitle("成员资料");

//        mGroupCode = getIntent().getStringExtra("groupCode");
        mUserId = getIntent().getStringExtra("userId");
        mRole = getIntent().getStringExtra("role");
        mInfoPresenter = new GetStaffInfoPresenter(this, mRole, mUserId);

        initData();
    }

    private void initData() {
        mInfoPresenter.getStaffInfo();
    }

    @Override
    public void onLoading(String loadingMessage) {
        showLoadingDialog(loadingMessage);
    }

    @Override
    public void onLoadFinished() {
        dismissLoadingDialog();
    }

    @Override
    public void onFail(int code, String errorMessage) {
        Toast.makeText(mContext, errorMessage, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void getInfoSuccess(StaffInfoEntity data) {
        genderTv.setText(Integer.valueOf(data.getSex()) == 1 ? "男" : "女");
        empNumTv.setText(data.getEmpNum());
        phoneTv.setText(data.getPhone());
        wechatTv.setText(data.getWechatNum());

    }
}
